package cn.linpq.label;
import cn.linpq.util.Tools;

import javax.swing.*;
import java.lang.ref.PhantomReference;

/**
 * Desc : 雷块类
 * ClassName : cn.linpq.label.MineLabel
 * @author : 林鹏群
 * @date : 2022/12/12 11:40
 */
public class MineLabel extends JLabel {
    //坐标
    private int row;
    private int col;
    //是否是雷
    private boolean mine;
    //是否是棋子
    private boolean flag;
    //是否是问号
    private boolean mark;
    //是否展开
    private boolean expand;
    //周围雷数
    private int aroundCounts;
    //右键次数
    private int rightClickCounts;

    private boolean doubleClick;

    public MineLabel(int row, int col) {
        this.row = row;
        this.col = col;
    }

    public void rightClick() {
        rightClickCounts++;
        this.setFlag(false);
        this.setMark(false);
        if(rightClickCounts%3==1){
            this.setIcon(Tools.flag);
            this.setFlag(true);
        }else if(rightClickCounts%3==2){
            this.setIcon(Tools.ask);
            this.setMark(true);
        }else {
            this.setIcon(Tools.blank);
        }
    }


    public void leftPress() {
        this.setIcon(Tools.mineCount[0]);
    }


    public boolean equals(MineLabel obj) {
        return this.col== obj.getCol()  && this.row == obj.getRow();
    }

    public int getRow() {
        return row;
    }

    public void setRow(int row) {
        this.row = row;
    }

    public int getCol() {
        return col;
    }

    public void setCol(int col) {
        this.col = col;
    }

    public boolean isMine() {
        return mine;
    }

    public void setMine(boolean mine) {
        this.mine = mine;
    }

    public boolean isFlag() {
        return flag;
    }

    public void setFlag(boolean flag) {
        this.flag = flag;
    }

    public boolean isMark() {
        return mark;
    }

    public void setMark(boolean mark) {
        this.mark = mark;
    }

    public boolean isExpand() {
        return expand;
    }

    public void setExpand(boolean expand) {
        this.expand = expand;
    }

    public int getAroundCounts() {
        return aroundCounts;
    }

    public void setAroundCounts(int aroundCounts) {
        this.aroundCounts = aroundCounts;
    }

    public int getRightClickCounts() {
        return rightClickCounts;
    }

    public void setRightClickCounts(int rightClickCounts) {
        this.rightClickCounts = rightClickCounts;
    }

    public boolean isDoubleClick() {
        return doubleClick;
    }

    public void setDoubleClick(boolean doubleClick) {
        this.doubleClick = doubleClick;
    }
}
